<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="js/swiper-4.2.6.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/swiper-4.2.6.min.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 服务中心-工单 -->
    <style>
        .main{
            display: none;
        }
        .main.selected{
            display: block;
        }
    </style>
</head>
<body>
<div class="scroll-content4 my-service-center-gd" style="overflow:auto;background: #f1f1f1;">
    <div class="top-public">
        <span class="public-center">服务中心</span>        
        <img src="images/left_icon.png" alt="" class="public-left">
        <img src="images/gd-jia.png" alt="" class="public-right">
    </div>
    <ul class="tab-bar">
        <li class="on_"  id="1"><span>全部</span></li>
        <li id="2"><span>进行中</span></li>
        <li id="3"><span>已完成</span></li>
    </ul>
    <div class="center-content">
        <div id="workList" class="main selected all">
            <!--<a href="my_servicecenter_gd_gh.html">-->
                <!--<div class="list">-->
                    <!--<p>你好</p>-->
                    <!--<span class="state">待客服接手 |</span>-->
                    <!--<span class="time">提交时间：<b>2018-09-12 17:31</b></span>-->
                <!--</div>-->
            <!--</a>-->
        </div>
        <div id="workConduct" class="main ing">
            <!-- <a href="my_servicecenter_gd_gh.html">
                <div class="list">
                    <p>你好</p>
                    <span class="state">待客服接手 |</span>
                    <span class="time">提交时间：<b>2018-09-12 17:31</b></span>
                </div>
            </a> -->
        </div>
        <div id="workFinish" class="main ed">
            <!-- <a href="my_servicecenter_gd_gh.html">
                <div class="list">
                    <p>你好</p>
                    <span class="state">待客服接手 |</span>
                    <span class="time">提交时间：<b>2018-09-12 17:31</b></span>
                </div>
            </a> -->
        </div>
    </div>
</div>
</body>
<script>
    // var serviceState = $('.tab-bar .on_')[0].id;
    // $.ajax({
    //     url: url() + 'api/Invoice/workList',    //请求的url地址
    //     dataType: "JSON",   //返回格式为json
    //     async: true,//请求是否异步，默认为异步，这也是ajax重要特性
    //     type: "POST",   //请求方式
    //     data:{
    //         user_id:user_id,
    //         serviceState:serviceState,
    //     },
    //     success: function (data) {
    //         console.log(data);
    //         //请求成功时处理
    //         if(data.status==1){
    //             // console.log(data);
    //             var html1 = '';
    //             $.each(data.data, function (i, item) {
    //                 html1+=' <a href="my_servicecenter_gd_gh.html?wid='+item.id+'">';
    //                 html1+='<div class="list">';
    //                 html1+=' <p>'+item.description+'</p>';
    //                 html1+='<span class="state">待客服接手 |</span>';
    //                 html1+='<span class="time">提交时间：<b>2018-09-12 17:31</b></span>';
    //                 html1+='</div>';
    //                 html1+='</a>';
    //             });
    //             $('#workConduct').html(html1);
    //         } else {
    //             alert(data.msg);
    //         }
    //     }
    // });
</script>

<script>
    $('.public-left').click(function(){
        // window.history.go(-1);
        window.location.href = 'my_servicecenter.html';
    });
    $('.public-right').click(function(){
        window.location.href = "my_servicecenter_xzcp.html";
    });

    $('.tab-bar li').click(function () {
        $('.tab-bar li').removeClass('on_');
        $(this).addClass('on_').siblings().removeClass('on_');
        $(".main").eq($(this).index()).show().siblings().hide();
    });

    $(function(){
        //验证是否登陆
        var user_id = sessionStorage.getItem('userId');
        if (user_id == null) {
            alert('请先登录！');
            window.location.href = 'login.html';
        }
        //删除储存的工单ID
        sessionStorage.removeItem('wid');
        //获取工单列表(全部)
        getGongdanall();
        //获取工单列表(进行中)
        getGongdanjx();
        //获取工单列表(已完成)
        getGongdanywc();
    });
    function getGongdanall() {
        var user_id = sessionStorage.getItem('userId');
        $.ajax({
            url: url() + 'api/Invoice/workList',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data:{
                user_id:user_id,
                serviceState:1,
            },
            success: function (data) {
                //请求成功时处理
                if(data.status==1){
                    // console.log(data);
                    var html1 = '';
                    $.each(data.data, function (i, item) {
                        var state = "";
                        if(item.status == 0){
                            state = '<span class="state">待客服接手 |</span>';
                        }else if(item.status == 1){
                            state = '<span class="state">客服处理中 |</span>';
                        }else if(item.status == 2){
                            state = '<span class="state" style="color: red">待您反馈 |</span>';
                        }else if(item.status == 3){
                            state = '<span class="state" style="color: #00a65a">待您评价 |</span>';
                        }else if(item.status == 4){
                            state = '<span class="state">工单已关闭 |</span>';
                        }
                        html1+='<a href="my_servicecenter_gd_gh.html">';
                        html1+='<div class="list" onclick="gongdanWid('+item.id+')">';
                        html1+='<p>'+item.description+'</p>';
                        html1+= state;
                        html1+='<span class="time">提交时间：<b>'+item.add_time+'</b></span>';
                        html1+='</div>';
                        html1+='</a>';
                    });
                    $('#workList').html(html1);
                } else {
                    $('#workConduct').html();
                    console.log(data.msg);
                }
            }
        });
    }
    function getGongdanjx(){
        var user_id = sessionStorage.getItem('userId');
        $.ajax({
            url: url() + 'api/Invoice/workList',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data:{
                user_id:user_id,
                serviceState:2,
            },
            success: function (data) {
                //请求成功时处理
                if(data.status==1){
                    // console.log(data);
                    var html1 = '';
                    $.each(data.data, function (i, item) {
                        var state = "";
                        if(item.status == 0){
                            state = '<span class="state">待客服接手 |</span>';
                        }else if(item.status == 1){
                            state = '<span class="state">客服处理中 |</span>';
                        }else if(item.status == 2){
                            state = '<span class="state" style="color: red">待您反馈 |</span>';
                        }else if(item.status == 3){
                            state = '<span class="state" style="color: #00a65a">待您评价 |</span>';
                        }else if(item.status == 4){
                            state = '<span class="state">工单已关闭 |</span>';
                        }
                        html1+='<a href="my_servicecenter_gd_gh.html">';
                        html1+='<div class="list" onclick="gongdanWid('+item.id+')">';
                        html1+='<p>'+item.description+'</p>';
                        html1+= state;
                        html1+='<span class="time">提交时间：<b>'+item.add_time+'</b></span>';
                        html1+='</div>';
                        html1+='</a>';
                    });
                    $('#workConduct').html(html1);
                } else {
                    $('#workConduct').html();
                    console.log(data.msg);
                }
            }
        });

    }
    function getGongdanywc(){
        var user_id = sessionStorage.getItem('userId');
        $.ajax({
            url: url() + 'api/Invoice/workList',    //请求的url地址
            dataType: "JSON",   //返回格式为json
            async: true,//请求是否异步，默认为异步，这也是ajax重要特性
            type: "POST",   //请求方式
            data:{
                user_id:user_id,
                serviceState:3,
            },
            success: function (data) {
                //请求成功时处理
                if(data.status==1){
                    // console.log(data);
                    var html1 = '';
                    $.each(data.data, function (i, item) {
                        var state = "";
                        if(item.status == 0){
                            state = '<span class="state">待客服接手 |</span>';
                        }else if(item.status == 1){
                            state = '<span class="state">客服处理中 |</span>';
                        }else if(item.status == 2){
                            state = '<span class="state" style="color: red">待您反馈 |</span>';
                        }else if(item.status == 3){
                            state = '<span class="state" style="color: #00a65a">待您评价 |</span>';
                        }else if(item.status == 4){
                            state = '<span class="state">工单已关闭 |</span>';
                        }
                        html1+='<a href="my_servicecenter_gd_gh.html">';
                        html1+='<div class="list" onclick="gongdanWid('+item.id+')">';
                        html1+='<p>'+item.description+'</p>';
                        html1+= state;
                        html1+='<span class="time">提交时间：<b>'+item.add_time+'</b></span>';
                        html1+='</div>';
                        html1+='</a>';
                    });
                    $('#workFinish').html(html1);
                } else {
                    $('#workConduct').html();
                    console.log(data.msg);
                }
            }
        });
    }

    //点击储存当前的工单ID
    function gongdanWid(obj) {
        sessionStorage.setItem('wid',obj);
    }

</script>
</html> 






